const fs = require('fs')
const path = require("path")
const moment = require('moment')

module.exports = (err) => {
    //定义日志文件路径
    let logFilePath = path.join(__dirname, '../', 'logs', moment().format('YYYY-MM-DD') + '.log')
    //读取日志文件
    let data = fs.readFileSync(logFilePath, 'utf-8')
    //替换状态
    data = data.replace(/ok$/, err)
    //替换之后写入日志
    fs.writeFileSync(logFilePath, data)
}